﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Controls.Common="http://imagin.tech/imagin/controls/common">
    <Style x:Key="Style.TextBox.Placeholder" TargetType="TextBlock">
        <Setter Property="FontFamily" Value="pack://application:,,,/Fonts/#Swis721 Cn BT"/>
        <Setter Property="FontSize" Value="15" />
        <Setter Property="Foreground" Value="{DynamicResource Brush.TextBox.Placeholder}" />
    </Style>

    <!-- ..................................................................................... -->

    <Style x:Key="Style.TextBoxBase" TargetType="{x:Type TextBoxBase}">
        <Setter Property="Background" Value="{DynamicResource Brush.TextBox.Background}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush.TextBox.Border}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CaretBrush" Value="{DynamicResource Brush.TextBox.Caret}" />
        <Setter Property="ContextMenu">
            <Setter.Value>
                <ContextMenu DataContext="{Binding PlacementTarget, RelativeSource={RelativeSource Self}}">
                    <MenuItem 
                        Command="{x:Static ApplicationCommands.Cut}"
                        Header="Cut"
                        InputGestureText="Ctrl + X"/>
                    <MenuItem 
                        Command="{x:Static ApplicationCommands.Copy}"
                        Header="Copy"
                        InputGestureText="Ctrl + C"/>
                    <MenuItem 
                        Command="{x:Static ApplicationCommands.Paste}"
                        Header="Paste"
                        InputGestureText="Ctrl + V"/>
                </ContextMenu>
            </Setter.Value>
        </Setter>
        <Setter Property="FontFamily" Value="pack://application:,,,/Fonts/#Swis721 Cn BT"/>
        <Setter Property="FontSize" Value="15" />
        <Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="3" />
        <Setter Property="SelectionBrush" Value="{DynamicResource Brush.TextBox.Selection}" />
        <Setter Property="SelectionOpacity" Value="0.4" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.TextBox.MouseOver.Border}" />
            </Trigger>
            <Trigger Property="IsFocused" Value="True">
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.TextBox.Focused.Border}" />
            </Trigger>
            <Trigger Property="IsReadOnly" Value="True">
                <Setter Property="SelectionBrush" Value="{DynamicResource Brush.TextBox.Disabled.Selection}" />
                <Setter Property="Opacity" Value="0.8" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="SelectionBrush" Value="{DynamicResource Brush.TextBox.Disabled.Selection}" />
                <Setter Property="Opacity" Value="0.8" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="Style.TextBox.Large" TargetType="{x:Type TextBox}" BasedOn="{StaticResource Style.TextBoxBase}">
        <Setter Property="AcceptsReturn" Value="True" />
        <Setter Property="MinHeight" Value="48" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
    </Style>

    <Style x:Key="Style.TextBox.Blank" TargetType="{x:Type TextBox}" BasedOn="{StaticResource Style.TextBoxBase}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorder}" />
        <Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Border BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" x:Name="border" Height="{TemplateBinding Height}">
                        <ScrollViewer HorizontalAlignment="Stretch"  x:Name="PART_ContentHost" VerticalContentAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Height="{TemplateBinding Height}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ..................................................................................... -->

    <Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}" BasedOn="{StaticResource Style.TextBoxBase}"/>

    <Style x:Key="{x:Type Controls.Common:TextBoxExt}" TargetType="{x:Type Controls.Common:TextBoxExt}" BasedOn="{StaticResource Style.TextBoxBase}">
        <Setter Property="PlaceholderStyle" Value="{StaticResource Style.TextBox.Placeholder}"/>
    </Style>

    <!-- ..................................................................................... -->

    <Style x:Key="{x:Type Controls.Common:EditableLabel}" TargetType="{x:Type Controls.Common:EditableLabel}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <!-- ..................................................................................... -->

    <Style x:Key="{x:Type Controls.Common:ByteUpDown}" TargetType="{x:Type Controls.Common:ByteUpDown}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <Style x:Key="{x:Type Controls.Common:DateTimeUpDown}" TargetType="{x:Type Controls.Common:DateTimeUpDown}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}">
        <Setter Property="DropDownStyle">
            <Setter.Value>
                <Style TargetType="Border">
                    <Setter Property="Background" Value="{DynamicResource Brush.Popup.Background}"/>
                    <Setter Property="BorderBrush" Value="{DynamicResource Brush.Popup.BorderBrush}"/>
                    <Setter Property="BorderThickness" Value="1"/>
                    <Setter Property="Padding" Value="10"/>
                </Style>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type Controls.Common:DecimalUpDown}" TargetType="{x:Type Controls.Common:DecimalUpDown}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <Style x:Key="{x:Type Controls.Common:DoubleUpDown}" TargetType="{x:Type Controls.Common:DoubleUpDown}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <Style x:Key="{x:Type Controls.Common:IntUpDown}" TargetType="{x:Type Controls.Common:IntUpDown}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <Style x:Key="{x:Type Controls.Common:LongUpDown}" TargetType="{x:Type Controls.Common:LongUpDown}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <Style x:Key="{x:Type Controls.Common:ShortUpDown}" TargetType="{x:Type Controls.Common:ShortUpDown}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <!-- ..................................................................................... -->

    <Style x:Key="{x:Type Controls.Common:AlphaNumericBox}" TargetType="{x:Type Controls.Common:AlphaNumericBox}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <Style x:Key="{x:Type Controls.Common:PasswordBox}" TargetType="{x:Type Controls.Common:PasswordBox}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}">
        <Setter Property="DotForeground" Value="{DynamicResource Brush.Text}"/>
        <Setter Property="DotSize" Value="6"/>
        <Setter Property="DotSpacing" Value="0,0,2,0"/>
        <Style.Triggers>
            <Trigger Property="IsFocused" Value="True">
                <Setter Property="DotForeground" Value="{DynamicResource Brush.TextBox.Focused.Border}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Type Controls.Common:FileBox}" TargetType="{x:Type Controls.Common:FileBox}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <Style x:Key="{x:Type Controls.Common:HexBox}" TargetType="{x:Type Controls.Common:HexBox}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <Style x:Key="{x:Type Controls.Common:RegexBox}" TargetType="{x:Type Controls.Common:RegexBox}" BasedOn="{StaticResource {x:Type Controls.Common:TextBoxExt}}"/>

    <!-- ..................................................................................... -->
    
    <Style x:Key="{x:Type RichTextBox}" TargetType="{x:Type RichTextBox}" BasedOn="{StaticResource Style.TextBoxBase}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="Padding" Value="10" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TextBoxBase">
                    <Border
                        Name="Bd"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}" 
                        SnapsToDevicePixels="True">
                        <ScrollViewer 
                            Name="PART_ContentHost"
                            SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type Controls.Common:TokenView}" TargetType="{x:Type Controls.Common:TokenView}" BasedOn="{StaticResource {x:Type RichTextBox}}">
        <Setter Property="Controls.Common:TextBoxBaseExtensions.EnableCopyCommand" Value="False"/>
        <Setter Property="Controls.Common:TextBoxBaseExtensions.EnableCutCommand" Value="False"/>
        <Setter Property="Controls.Common:TextBoxBaseExtensions.EnablePasteCommand" Value="False"/>
        <Setter Property="Controls.Common:FrameworkElementExtensions.EnableContextMenu" Value="False"/>
        <Setter Property="Padding" Value="3,7"/>
    </Style>
</ResourceDictionary>